function dvdtheta = gradv(H,Nu,tau,tc0)
% Gradient of flow utility term (v)

% Key: column 1 = dv/dmu; columns 2-3 = dv/deta; columns 4:25 = dv/dchi 

dvdtheta = cell(1,tau);

for idx1 = 1:tau
    dvdtheta{idx1} = zeros(H-1,(H-1+tau-1+1),Nu);
    for idx2 = 1:Nu
        dvdtheta{idx1}(:,1,idx2) = tc0(idx2,:)';
        dvdtheta{idx1}(:,2,idx2) = 1*(idx1==1);
        dvdtheta{idx1}(:,3,idx2) = 1*(idx1==2);
        dvdtheta{idx1}(:,4:end,idx2) = eye(H-1);
    end    
end